home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / util / Scanner.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  18.6 KB  |  1,309 lines

  1. package java.util;
  2.  
  3. import java.io.Closeable;
  4. import java.io.File;
  5. import java.io.FileInputStream;
  6. import java.io.FileNotFoundException;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.io.InputStreamReader;
  10. import java.io.StringReader;
  11. import java.io.UnsupportedEncodingException;
  12. import java.math.BigDecimal;
  13. import java.math.BigInteger;
  14. import java.nio.CharBuffer;
  15. import java.nio.channels.Channels;
  16. import java.nio.channels.ReadableByteChannel;
  17. import java.nio.charset.Charset;
  18. import java.text.DecimalFormat;
  19. import java.text.DecimalFormatSymbols;
  20. import java.text.NumberFormat;
  21. import java.util.regex.MatchResult;
  22. import java.util.regex.Matcher;
  23. import java.util.regex.Pattern;
  24. import sun.misc.LRUCache;
  25.  
  26. public final class Scanner implements Iterator<String> {
  27.    private CharBuffer buf;
  28.    private static final int BUFFER_SIZE = 1024;
  29.    private int position;
  30.    private Matcher matcher;
  31.    private Pattern delimPattern;
  32.    private Pattern hasNextPattern;
  33.    private int hasNextPosition;
  34.    private String hasNextResult;
  35.    private Readable source;
  36.    private boolean sourceClosed;
  37.    private boolean needInput;
  38.    private boolean skipped;
  39.    private int savedScannerPosition;
  40.    private Object typeCache;
  41.    private boolean matchValid;
  42.    private boolean closed;
  43.    private int radix;
  44.    private int defaultRadix;
  45.    private Locale locale;
  46.    private LRUCache<String, Pattern> patternCache;
  47.    private IOException lastException;
  48.    private static Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");
  49.    private static Pattern FIND_ANY_PATTERN = Pattern.compile("(?s).*");
  50.    private static Pattern NON_ASCII_DIGIT = Pattern.compile("[\\p{javaDigit}&&[^0-9]]");
  51.    private String groupSeparator;
  52.    private String decimalSeparator;
  53.    private String nanString;
  54.    private String infinityString;
  55.    private String positivePrefix;
  56.    private String negativePrefix;
  57.    private String positiveSuffix;
  58.    private String negativeSuffix;
  59.    private static volatile Pattern boolPattern;
  60.    private static final String BOOLEAN_PATTERN = "true|false";
  61.    private Pattern integerPattern;
  62.    private String digits;
  63.    private String non0Digit;
  64.    private int SIMPLE_GROUP_INDEX;
  65.    private static volatile Pattern separatorPattern;
  66.    private static volatile Pattern linePattern;
  67.    private static final String LINE_SEPARATOR_PATTERN = "\r\n|[\n\r\u2028\u2029\u0085]";
  68.    private static final String LINE_PATTERN = ".*(\r\n|[\n\r\u2028\u2029\u0085])|.+$";
  69.    private Pattern floatPattern;
  70.    private Pattern decimalPattern;
  71.  
  72.    private static Pattern boolPattern() {
  73.       Pattern var0 = boolPattern;
  74.       if (var0 == null) {
  75.          boolPattern = var0 = Pattern.compile("true|false", 2);
  76.       }
  77.  
  78.       return var0;
  79.    }
  80.  
  81.    private String buildIntegerPatternString() {
  82.       String var1 = this.digits.substring(0, this.radix);
  83.       String var2 = "((?i)[" + var1 + "]|\\p{javaDigit})";
  84.       String var3 = "(" + this.non0Digit + var2 + "?" + var2 + "?(" + this.groupSeparator + var2 + var2 + var2 + ")+)";
  85.       String var4 = "((" + var2 + "++)|" + var3 + ")";
  86.       String var5 = "([-+]?(" + var4 + "))";
  87.       String var6 = this.negativePrefix + var4 + this.negativeSuffix;
  88.       String var7 = this.positivePrefix + var4 + this.positiveSuffix;
  89.       return "(" + var5 + ")|(" + var7 + ")|(" + var6 + ")";
  90.    }
  91.  
  92.    private Pattern integerPattern() {
  93.       if (this.integerPattern == null) {
  94.          this.integerPattern = (Pattern)this.patternCache.forName(this.buildIntegerPatternString());
  95.       }
  96.  
  97.       return this.integerPattern;
  98.    }
  99.  
  100.    private static Pattern separatorPattern() {
  101.       Pattern var0 = separatorPattern;
  102.       if (var0 == null) {
  103.          separatorPattern = var0 = Pattern.compile("\r\n|[\n\r\u2028\u2029\u0085]");
  104.       }
  105.  
  106.       return var0;
  107.    }
  108.  
  109.    private static Pattern linePattern() {
  110.       Pattern var0 = linePattern;
  111.       if (var0 == null) {
  112.          linePattern = var0 = Pattern.compile(".*(\r\n|[\n\r\u2028\u2029\u0085])|.+$");
  113.       }
  114.  
  115.       return var0;
  116.    }
  117.  
  118.    private void buildFloatAndDecimalPattern() {
  119.       String var1 = "([0-9]|(\\p{javaDigit}))";
  120.       String var2 = "([eE][+-]?" + var1 + "+)?";
  121.       String var3 = "(" + this.non0Digit + var1 + "?" + var1 + "?(" + this.groupSeparator + var1 + var1 + var1 + ")+)";
  122.       String var4 = "((" + var1 + "++)|" + var3 + ")";
  123.       String var5 = "(" + var4 + "|" + var4 + this.decimalSeparator + var1 + "*+|" + this.decimalSeparator + var1 + "++)";
  124.       String var6 = "(NaN|" + this.nanString + "|Infinity|" + this.infinityString + ")";
  125.       String var7 = "(" + this.positivePrefix + var5 + this.positiveSuffix + var2 + ")";
  126.       String var8 = "(" + this.negativePrefix + var5 + this.negativeSuffix + var2 + ")";
  127.       String var9 = "(([-+]?" + var5 + var2 + ")|" + var7 + "|" + var8 + ")";
  128.       String var10 = "[-+]?0[xX][0-9a-fA-F]*\\.[0-9a-fA-F]+([pP][-+]?[0-9]+)?";
  129.       String var11 = "(" + this.positivePrefix + var6 + this.positiveSuffix + ")";
  130.       String var12 = "(" + this.negativePrefix + var6 + this.negativeSuffix + ")";
  131.       String var13 = "(([-+]?" + var6 + ")|" + var11 + "|" + var12 + ")";
  132.       this.floatPattern = Pattern.compile(var9 + "|" + var10 + "|" + var13);
  133.       this.decimalPattern = Pattern.compile(var9);
  134.    }
  135.  
  136.    private Pattern floatPattern() {
  137.       if (this.floatPattern == null) {
  138.          this.buildFloatAndDecimalPattern();
  139.       }
  140.  
  141.       return this.floatPattern;
  142.    }
  143.  
  144.    private Pattern decimalPattern() {
  145.       if (this.decimalPattern == null) {
  146.          this.buildFloatAndDecimalPattern();
  147.       }
  148.  
  149.       return this.decimalPattern;
  150.    }
  151.  
  152.    private Scanner(Readable var1, Pattern var2) {
  153.       this.sourceClosed = false;
  154.       this.needInput = false;
  155.       this.skipped = false;
  156.       this.savedScannerPosition = -1;
  157.       this.typeCache = null;
  158.       this.matchValid = false;
  159.       this.closed = false;
  160.       this.radix = 10;
  161.       this.defaultRadix = 10;
  162.       this.locale = null;
  163.       this.patternCache = new 1(this, 7);
  164.       this.groupSeparator = "\\,";
  165.       this.decimalSeparator = "\\.";
  166.       this.nanString = "NaN";
  167.       this.infinityString = "Infinity";
  168.       this.positivePrefix = "";
  169.       this.negativePrefix = "\\-";
  170.       this.positiveSuffix = "";
  171.       this.negativeSuffix = "";
  172.       this.digits = "0123456789abcdefghijklmnopqrstuvwxyz";
  173.       this.non0Digit = "[\\p{javaDigit}&&[^0]]";
  174.       this.SIMPLE_GROUP_INDEX = 5;
  175.       if (var1 == null) {
  176.          throw new NullPointerException("source");
  177.       } else if (var2 == null) {
  178.          throw new NullPointerException("pattern");
  179.       } else {
  180.          this.source = var1;
  181.          this.delimPattern = var2;
  182.          this.buf = CharBuffer.allocate(1024);
  183.          this.buf.limit(0);
  184.          this.matcher = this.delimPattern.matcher(this.buf);
  185.          this.matcher.useTransparentBounds(true);
  186.          this.matcher.useAnchoringBounds(false);
  187.          this.useLocale(Locale.getDefault());
  188.       }
  189.    }
  190.  
  191.    public Scanner(Readable var1) {
  192.       this(var1, WHITESPACE_PATTERN);
  193.    }
  194.  
  195.    public Scanner(InputStream var1) {
  196.       this((Readable)(new InputStreamReader(var1)), (Pattern)WHITESPACE_PATTERN);
  197.    }
  198.  
  199.    public Scanner(InputStream var1, String var2) {
  200.       this(makeReadable(var1, var2), WHITESPACE_PATTERN);
  201.    }
  202.  
  203.    private static Readable makeReadable(InputStream var0, String var1) {
  204.       if (var0 == null) {
  205.          throw new NullPointerException("source");
  206.       } else {
  207.          Object var2 = null;
  208.  
  209.          try {
  210.             InputStreamReader var6 = new InputStreamReader(var0, var1);
  211.             return var6;
  212.          } catch (UnsupportedEncodingException var5) {
  213.             IllegalArgumentException var4 = new IllegalArgumentException();
  214.             var4.initCause(var5);
  215.             throw var4;
  216.          }
  217.       }
  218.    }
  219.  
  220.    public Scanner(File var1) throws FileNotFoundException {
  221.       this((ReadableByteChannel)(new FileInputStream(var1)).getChannel());
  222.    }
  223.  
  224.    public Scanner(File var1, String var2) throws FileNotFoundException {
  225.       this((ReadableByteChannel)(new FileInputStream(var1)).getChannel(), (String)var2);
  226.    }
  227.  
  228.    public Scanner(String var1) {
  229.       this((Readable)(new StringReader(var1)), (Pattern)WHITESPACE_PATTERN);
  230.    }
  231.  
  232.    public Scanner(ReadableByteChannel var1) {
  233.       this(makeReadable(var1), WHITESPACE_PATTERN);
  234.    }
  235.  
  236.    private static Readable makeReadable(ReadableByteChannel var0) {
  237.       if (var0 == null) {
  238.          throw new NullPointerException("source");
  239.       } else {
  240.          String var1 = Charset.defaultCharset().name();
  241.          return Channels.newReader(var0, Charset.defaultCharset().name());
  242.       }
  243.    }
  244.  
  245.    public Scanner(ReadableByteChannel var1, String var2) {
  246.       this(makeReadable(var1, var2), WHITESPACE_PATTERN);
  247.    }
  248.  
  249.    private static Readable makeReadable(ReadableByteChannel var0, String var1) {
  250.       if (var0 == null) {
  251.          throw new NullPointerException("source");
  252.       } else if (!Charset.isSupported(var1)) {
  253.          throw new IllegalArgumentException(var1);
  254.       } else {
  255.          return Channels.newReader(var0, var1);
  256.       }
  257.    }
  258.  
  259.    private void saveState() {
  260.       this.savedScannerPosition = this.position;
  261.    }
  262.  
  263.    private void revertState() {
  264.       this.position = this.savedScannerPosition;
  265.       this.savedScannerPosition = -1;
  266.       this.skipped = false;
  267.    }
  268.  
  269.    private boolean revertState(boolean var1) {
  270.       this.position = this.savedScannerPosition;
  271.       this.savedScannerPosition = -1;
  272.       this.skipped = false;
  273.       return var1;
  274.    }
  275.  
  276.    private void cacheResult() {
  277.       this.hasNextResult = this.matcher.group();
  278.       this.hasNextPosition = this.matcher.end();
  279.       this.hasNextPattern = this.matcher.pattern();
  280.    }
  281.  
  282.    private void cacheResult(String var1) {
  283.       this.hasNextResult = var1;
  284.       this.hasNextPosition = this.matcher.end();
  285.       this.hasNextPattern = this.matcher.pattern();
  286.    }
  287.  
  288.    private void clearCaches() {
  289.       this.hasNextPattern = null;
  290.       this.typeCache = null;
  291.    }
  292.  
  293.    private String getCachedResult() {
  294.       this.position = this.hasNextPosition;
  295.       this.hasNextPattern = null;
  296.       this.typeCache = null;
  297.       return this.hasNextResult;
  298.    }
  299.  
  300.    private void useTypeCache() {
  301.       if (this.closed) {
  302.          throw new IllegalStateException("Scanner closed");
  303.       } else {
  304.          this.position = this.hasNextPosition;
  305.          this.hasNextPattern = null;
  306.          this.typeCache = null;
  307.       }
  308.    }
  309.  
  310.    private void readInput() {
  311.       if (this.buf.limit() == this.buf.capacity()) {
  312.          this.makeSpace();
  313.       }
  314.  
  315.       int var1 = this.buf.position();
  316.       this.buf.position(this.buf.limit());
  317.       this.buf.limit(this.buf.capacity());
  318.       int var2 = 0;
  319.  
  320.       try {
  321.          var2 = this.source.read(this.buf);
  322.       } catch (IOException var4) {
  323.          this.lastException = var4;
  324.          var2 = -1;
  325.       }
  326.  
  327.       if (var2 == -1) {
  328.          this.sourceClosed = true;
  329.          this.needInput = false;
  330.       }
  331.  
  332.       if (var2 > 0) {
  333.          this.needInput = false;
  334.       }
  335.  
  336.       this.buf.limit(this.buf.position());
  337.       this.buf.position(var1);
  338.    }
  339.  
  340.    private boolean makeSpace() {
  341.       this.clearCaches();
  342.       int var1 = this.savedScannerPosition == -1 ? this.position : this.savedScannerPosition;
  343.       this.buf.position(var1);
  344.       if (var1 > 0) {
  345.          this.buf.compact();
  346.          this.translateSavedIndexes(var1);
  347.          this.position -= var1;
  348.          this.buf.flip();
  349.          return true;
  350.       } else {
  351.          int var2 = this.buf.capacity() * 2;
  352.          CharBuffer var3 = CharBuffer.allocate(var2);
  353.          var3.put(this.buf);
  354.          var3.flip();
  355.          this.translateSavedIndexes(var1);
  356.          this.position -= var1;
  357.          this.buf = var3;
  358.          this.matcher.reset(this.buf);
  359.          return true;
  360.       }
  361.    }
  362.  
  363.    private void translateSavedIndexes(int var1) {
  364.       if (this.savedScannerPosition != -1) {
  365.          this.savedScannerPosition -= var1;
  366.       }
  367.  
  368.    }
  369.  
  370.    private void throwFor() {
  371.       this.skipped = false;
  372.       if (this.sourceClosed && this.position == this.buf.limit()) {
  373.          throw new NoSuchElementException();
  374.       } else {
  375.          throw new InputMismatchException();
  376.       }
  377.    }
  378.  
  379.    private boolean hasTokenInBuffer() {
  380.       this.matchValid = false;
  381.       this.matcher.usePattern(this.delimPattern);
  382.       this.matcher.region(this.position, this.buf.limit());
  383.       if (this.matcher.lookingAt()) {
  384.          this.position = this.matcher.end();
  385.       }
  386.  
  387.       return this.position != this.buf.limit();
  388.    }
  389.  
  390.    private String getCompleteTokenInBuffer(Pattern var1) {
  391.       this.matchValid = false;
  392.       this.matcher.usePattern(this.delimPattern);
  393.       if (!this.skipped) {
  394.          this.matcher.region(this.position, this.buf.limit());
  395.          if (this.matcher.lookingAt()) {
  396.             if (this.matcher.hitEnd() && !this.sourceClosed) {
  397.                this.needInput = true;
  398.                return null;
  399.             }
  400.  
  401.             this.skipped = true;
  402.             this.position = this.matcher.end();
  403.          }
  404.       }
  405.  
  406.       if (this.position == this.buf.limit()) {
  407.          if (this.sourceClosed) {
  408.             return null;
  409.          } else {
  410.             this.needInput = true;
  411.             return null;
  412.          }
  413.       } else {
  414.          this.matcher.region(this.position, this.buf.limit());
  415.          boolean var2 = this.matcher.find();
  416.          if (var2 && this.matcher.end() == this.position) {
  417.             var2 = this.matcher.find();
  418.          }
  419.  
  420.          if (var2) {
  421.             if (this.matcher.requireEnd() && !this.sourceClosed) {
  422.                this.needInput = true;
  423.                return null;
  424.             } else {
  425.                int var5 = this.matcher.start();
  426.                if (var1 == null) {
  427.                   var1 = FIND_ANY_PATTERN;
  428.                }
  429.  
  430.                this.matcher.usePattern(var1);
  431.                this.matcher.region(this.position, var5);
  432.                if (this.matcher.matches()) {
  433.                   String var4 = this.matcher.group();
  434.                   this.position = this.matcher.end();
  435.                   return var4;
  436.                } else {
  437.                   return null;
  438.                }
  439.             }
  440.          } else if (this.sourceClosed) {
  441.             if (var1 == null) {
  442.                var1 = FIND_ANY_PATTERN;
  443.             }
  444.  
  445.             this.matcher.usePattern(var1);
  446.             this.matcher.region(this.position, this.buf.limit());
  447.             if (this.matcher.matches()) {
  448.                String var3 = this.matcher.group();
  449.                this.position = this.matcher.end();
  450.                return var3;
  451.             } else {
  452.                return null;
  453.             }
  454.          } else {
  455.             this.needInput = true;
  456.             return null;
  457.          }
  458.       }
  459.    }
  460.  
  461.    private String findPatternInBuffer(Pattern var1, int var2) {
  462.       this.matchValid = false;
  463.       this.matcher.usePattern(var1);
  464.       int var3 = this.buf.limit();
  465.       int var4 = -1;
  466.       int var5 = var3;
  467.       if (var2 > 0) {
  468.          var4 = this.position + var2;
  469.          if (var4 < var3) {
  470.             var5 = var4;
  471.          }
  472.       }
  473.  
  474.       this.matcher.region(this.position, var5);
  475.       if (this.matcher.find()) {
  476.          if (this.matcher.hitEnd() && !this.sourceClosed) {
  477.             if (var5 != var4) {
  478.                this.needInput = true;
  479.                return null;
  480.             }
  481.  
  482.             if (var5 == var4 && this.matcher.requireEnd()) {
  483.                this.needInput = true;
  484.                return null;
  485.             }
  486.          }
  487.  
  488.          this.position = this.matcher.end();
  489.          return this.matcher.group();
  490.       } else if (this.sourceClosed) {
  491.          return null;
  492.       } else {
  493.          if (var2 == 0 || var5 != var4) {
  494.             this.needInput = true;
  495.          }
  496.  
  497.          return null;
  498.       }
  499.    }
  500.  
  501.    private String matchPatternInBuffer(Pattern var1) {
  502.       this.matchValid = false;
  503.       this.matcher.usePattern(var1);
  504.       this.matcher.region(this.position, this.buf.limit());
  505.       if (this.matcher.lookingAt()) {
  506.          if (this.matcher.hitEnd() && !this.sourceClosed) {
  507.             this.needInput = true;
  508.             return null;
  509.          } else {
  510.             this.position = this.matcher.end();
  511.             return this.matcher.group();
  512.          }
  513.       } else if (this.sourceClosed) {
  514.          return null;
  515.       } else {
  516.          this.needInput = true;
  517.          return null;
  518.       }
  519.    }
  520.  
  521.    private void ensureOpen() {
  522.       if (this.closed) {
  523.          throw new IllegalStateException("Scanner closed");
  524.       }
  525.    }
  526.  
  527.    public void close() {
  528.       if (!this.closed) {
  529.          if (this.source instanceof Closeable) {
  530.             try {
  531.                ((Closeable)this.source).close();
  532.             } catch (IOException var2) {
  533.                this.lastException = var2;
  534.             }
  535.          }
  536.  
  537.          this.sourceClosed = true;
  538.          this.source = null;
  539.          this.closed = true;
  540.       }
  541.    }
  542.  
  543.    public IOException ioException() {
  544.       return this.lastException;
  545.    }
  546.  
  547.    public Pattern delimiter() {
  548.       return this.delimPattern;
  549.    }
  550.  
  551.    public Scanner useDelimiter(Pattern var1) {
  552.       this.delimPattern = var1;
  553.       return this;
  554.    }
  555.  
  556.    public Scanner useDelimiter(String var1) {
  557.       this.delimPattern = (Pattern)this.patternCache.forName(var1);
  558.       return this;
  559.    }
  560.  
  561.    public Locale locale() {
  562.       return this.locale;
  563.    }
  564.  
  565.    public Scanner useLocale(Locale var1) {
  566.       if (var1.equals(this.locale)) {
  567.          return this;
  568.       } else {
  569.          this.locale = var1;
  570.          DecimalFormat var2 = (DecimalFormat)NumberFormat.getNumberInstance(var1);
  571.          DecimalFormatSymbols var3 = DecimalFormatSymbols.getInstance(var1);
  572.          this.groupSeparator = "\\" + var3.getGroupingSeparator();
  573.          this.decimalSeparator = "\\" + var3.getDecimalSeparator();
  574.          this.nanString = "\\Q" + var3.getNaN() + "\\E";
  575.          this.infinityString = "\\Q" + var3.getInfinity() + "\\E";
  576.          this.positivePrefix = var2.getPositivePrefix();
  577.          if (this.positivePrefix.length() > 0) {
  578.             this.positivePrefix = "\\Q" + this.positivePrefix + "\\E";
  579.          }
  580.  
  581.          this.negativePrefix = var2.getNegativePrefix();
  582.          if (this.negativePrefix.length() > 0) {
  583.             this.negativePrefix = "\\Q" + this.negativePrefix + "\\E";
  584.          }
  585.  
  586.          this.positiveSuffix = var2.getPositiveSuffix();
  587.          if (this.positiveSuffix.length() > 0) {
  588.             this.positiveSuffix = "\\Q" + this.positiveSuffix + "\\E";
  589.          }
  590.  
  591.          this.negativeSuffix = var2.getNegativeSuffix();
  592.          if (this.negativeSuffix.length() > 0) {
  593.             this.negativeSuffix = "\\Q" + this.negativeSuffix + "\\E";
  594.          }
  595.  
  596.          this.integerPattern = null;
  597.          this.floatPattern = null;
  598.          return this;
  599.       }
  600.    }
  601.  
  602.    public int radix() {
  603.       return this.defaultRadix;
  604.    }
  605.  
  606.    public Scanner useRadix(int var1) {
  607.       if (var1 >= 2 && var1 <= 36) {
  608.          if (this.defaultRadix == var1) {
  609.             return this;
  610.          } else {
  611.             this.defaultRadix = var1;
  612.             this.integerPattern = null;
  613.             return this;
  614.          }
  615.       } else {
  616.          throw new IllegalArgumentException("radix:" + var1);
  617.       }
  618.    }
  619.  
  620.    private void setRadix(int var1) {
  621.       if (this.radix != var1) {
  622.          this.integerPattern = null;
  623.          this.radix = var1;
  624.       }
  625.  
  626.    }
  627.  
  628.    public MatchResult match() {
  629.       if (!this.matchValid) {
  630.          throw new IllegalStateException("No match result available");
  631.       } else {
  632.          return this.matcher.toMatchResult();
  633.       }
  634.    }
  635.  
  636.    public String toString() {
  637.       StringBuilder var1 = new StringBuilder();
  638.       var1.append("java.util.Scanner");
  639.       var1.append("[delimiters=" + this.delimPattern + "]");
  640.       var1.append("[position=" + this.position + "]");
  641.       var1.append("[match valid=" + this.matchValid + "]");
  642.       var1.append("[need input=" + this.needInput + "]");
  643.       var1.append("[source closed=" + this.sourceClosed + "]");
  644.       var1.append("[skipped=" + this.skipped + "]");
  645.       var1.append("[group separator=" + this.groupSeparator + "]");
  646.       var1.append("[decimal separator=" + this.decimalSeparator + "]");
  647.       var1.append("[positive prefix=" + this.positivePrefix + "]");
  648.       var1.append("[negative prefix=" + this.negativePrefix + "]");
  649.       var1.append("[positive suffix=" + this.positiveSuffix + "]");
  650.       var1.append("[negative suffix=" + this.negativeSuffix + "]");
  651.       var1.append("[NaN string=" + this.nanString + "]");
  652.       var1.append("[infinity string=" + this.infinityString + "]");
  653.       return var1.toString();
  654.    }
  655.  
  656.    public boolean hasNext() {
  657.       this.ensureOpen();
  658.       this.saveState();
  659.  
  660.       while(!this.sourceClosed) {
  661.          if (this.hasTokenInBuffer()) {
  662.             return this.revertState(true);
  663.          }
  664.  
  665.          this.readInput();
  666.       }
  667.  
  668.       boolean var1 = this.hasTokenInBuffer();
  669.       return this.revertState(var1);
  670.    }
  671.  
  672.    public String next() {
  673.       this.ensureOpen();
  674.       this.clearCaches();
  675.  
  676.       while(true) {
  677.          String var1 = this.getCompleteTokenInBuffer((Pattern)null);
  678.          if (var1 != null) {
  679.             this.matchValid = true;
  680.             this.skipped = false;
  681.             return var1;
  682.          }
  683.  
  684.          if (this.needInput) {
  685.             this.readInput();
  686.          } else {
  687.             this.throwFor();
  688.          }
  689.       }
  690.    }
  691.  
  692.    public void remove() {
  693.       throw new UnsupportedOperationException();
  694.    }
  695.  
  696.    public boolean hasNext(String var1) {
  697.       return this.hasNext((Pattern)this.patternCache.forName(var1));
  698.    }
  699.  
  700.    public String next(String var1) {
  701.       return this.next((Pattern)this.patternCache.forName(var1));
  702.    }
  703.  
  704.    public boolean hasNext(Pattern var1) {
  705.       this.ensureOpen();
  706.       if (var1 == null) {
  707.          throw new NullPointerException();
  708.       } else {
  709.          this.hasNextPattern = null;
  710.          this.saveState();
  711.  
  712.          while(this.getCompleteTokenInBuffer(var1) == null) {
  713.             if (!this.needInput) {
  714.                return this.revertState(false);
  715.             }
  716.  
  717.             this.readInput();
  718.          }
  719.  
  720.          this.matchValid = true;
  721.          this.cacheResult();
  722.          return this.revertState(true);
  723.       }
  724.    }
  725.  
  726.    public String next(Pattern var1) {
  727.       this.ensureOpen();
  728.       if (var1 == null) {
  729.          throw new NullPointerException();
  730.       } else if (this.hasNextPattern == var1) {
  731.          return this.getCachedResult();
  732.       } else {
  733.          this.clearCaches();
  734.  
  735.          while(true) {
  736.             String var2 = this.getCompleteTokenInBuffer(var1);
  737.             if (var2 != null) {
  738.                this.matchValid = true;
  739.                this.skipped = false;
  740.                return var2;
  741.             }
  742.  
  743.             if (this.needInput) {
  744.                this.readInput();
  745.             } else {
  746.                this.throwFor();
  747.             }
  748.          }
  749.       }
  750.    }
  751.  
  752.    public boolean hasNextLine() {
  753.       this.saveState();
  754.       String var1 = this.findWithinHorizon((Pattern)linePattern(), 0);
  755.       if (var1 != null) {
  756.          MatchResult var2 = this.match();
  757.          String var3 = var2.group(1);
  758.          if (var3 != null) {
  759.             var1 = var1.substring(0, var1.length() - var3.length());
  760.             this.cacheResult(var1);
  761.          } else {
  762.             this.cacheResult();
  763.          }
  764.       }
  765.  
  766.       this.revertState();
  767.       return var1 != null;
  768.    }
  769.  
  770.    public String nextLine() {
  771.       if (this.hasNextPattern == linePattern()) {
  772.          return this.getCachedResult();
  773.       } else {
  774.          this.clearCaches();
  775.          String var1 = this.findWithinHorizon((Pattern)linePattern, 0);
  776.          if (var1 == null) {
  777.             throw new NoSuchElementException("No line found");
  778.          } else {
  779.             MatchResult var2 = this.match();
  780.             String var3 = var2.group(1);
  781.             if (var3 != null) {
  782.                var1 = var1.substring(0, var1.length() - var3.length());
  783.             }
  784.  
  785.             if (var1 == null) {
  786.                throw new NoSuchElementException();
  787.             } else {
  788.                return var1;
  789.             }
  790.          }
  791.       }
  792.    }
  793.  
  794.    public String findInLine(String var1) {
  795.       return this.findInLine((Pattern)this.patternCache.forName(var1));
  796.    }
  797.  
  798.    public String findInLine(Pattern var1) {
  799.       this.ensureOpen();
  800.       if (var1 == null) {
  801.          throw new NullPointerException();
  802.       } else {
  803.          this.clearCaches();
  804.          int var2 = 0;
  805.          this.saveState();
  806.  
  807.          while(true) {
  808.             String var3 = this.findPatternInBuffer(separatorPattern(), 0);
  809.             if (var3 != null) {
  810.                var2 = this.matcher.start();
  811.                break;
  812.             }
  813.  
  814.             if (!this.needInput) {
  815.                var2 = this.buf.limit();
  816.                break;
  817.             }
  818.  
  819.             this.readInput();
  820.          }
  821.  
  822.          this.revertState();
  823.          int var5 = var2 - this.position;
  824.          return var5 == 0 ? null : this.findWithinHorizon(var1, var5);
  825.       }
  826.    }
  827.  
  828.    public String findWithinHorizon(String var1, int var2) {
  829.       return this.findWithinHorizon((Pattern)this.patternCache.forName(var1), var2);
  830.    }
  831.  
  832.    public String findWithinHorizon(Pattern var1, int var2) {
  833.       this.ensureOpen();
  834.       if (var1 == null) {
  835.          throw new NullPointerException();
  836.       } else if (var2 < 0) {
  837.          throw new IllegalArgumentException("horizon < 0");
  838.       } else {
  839.          this.clearCaches();
  840.  
  841.          while(true) {
  842.             String var3 = this.findPatternInBuffer(var1, var2);
  843.             if (var3 != null) {
  844.                this.matchValid = true;
  845.                return var3;
  846.             }
  847.  
  848.             if (!this.needInput) {
  849.                return null;
  850.             }
  851.  
  852.             this.readInput();
  853.          }
  854.       }
  855.    }
  856.  
  857.    public Scanner skip(Pattern var1) {
  858.       this.ensureOpen();
  859.       if (var1 == null) {
  860.          throw new NullPointerException();
  861.       } else {
  862.          this.clearCaches();
  863.  
  864.          while(true) {
  865.             String var2 = this.matchPatternInBuffer(var1);
  866.             if (var2 != null) {
  867.                this.matchValid = true;
  868.                this.position = this.matcher.end();
  869.                return this;
  870.             }
  871.  
  872.             if (!this.needInput) {
  873.                throw new NoSuchElementException();
  874.             }
  875.  
  876.             this.readInput();
  877.          }
  878.       }
  879.    }
  880.  
  881.    public Scanner skip(String var1) {
  882.       return this.skip((Pattern)this.patternCache.forName(var1));
  883.    }
  884.  
  885.    public boolean hasNextBoolean() {
  886.       return this.hasNext(boolPattern());
  887.    }
  888.  
  889.    public boolean nextBoolean() {
  890.       this.clearCaches();
  891.       return Boolean.parseBoolean(this.next(boolPattern()));
  892.    }
  893.  
  894.    public boolean hasNextByte() {
  895.       return this.hasNextByte(this.defaultRadix);
  896.    }
  897.  
  898.    public boolean hasNextByte(int var1) {
  899.       this.setRadix(var1);
  900.       boolean var2 = this.hasNext(this.integerPattern());
  901.       if (var2) {
  902.          try {
  903.             String var3 = this.matcher.group(this.SIMPLE_GROUP_INDEX) == null ? this.processIntegerToken(this.hasNextResult) : this.hasNextResult;
  904.             this.typeCache = Byte.parseByte(var3, var1);
  905.          } catch (NumberFormatException var4) {
  906.             var2 = false;
  907.          }
  908.       }
  909.  
  910.       return var2;
  911.    }
  912.  
  913.    public byte nextByte() {
  914.       return this.nextByte(this.defaultRadix);
  915.    }
  916.  
  917.    public byte nextByte(int var1) {
  918.       if (this.typeCache != null && this.typeCache instanceof Byte && this.radix == var1) {
  919.          byte var4 = (Byte)this.typeCache;
  920.          this.useTypeCache();
  921.          return var4;
  922.       } else {
  923.          this.setRadix(var1);
  924.          this.clearCaches();
  925.  
  926.          try {
  927.             String var2 = this.next(this.integerPattern());
  928.             if (this.matcher.group(this.SIMPLE_GROUP_INDEX) == null) {
  929.                var2 = this.processIntegerToken(var2);
  930.             }
  931.  
  932.             return Byte.parseByte(var2, var1);
  933.          } catch (NumberFormatException var3) {
  934.             this.position = this.matcher.start();
  935.             throw new InputMismatchException(var3.getMessage());
  936.          }
  937.       }
  938.    }
  939.  
  940.    public boolean hasNextShort() {
  941.       return this.hasNextShort(this.defaultRadix);
  942.    }
  943.  
  944.    public boolean hasNextShort(int var1) {
  945.       this.setRadix(var1);
  946.       boolean var2 = this.hasNext(this.integerPattern());
  947.       if (var2) {
  948.          try {
  949.             String var3 = this.matcher.group(this.SIMPLE_GROUP_INDEX) == null ? this.processIntegerToken(this.hasNextResult) : this.hasNextResult;
  950.             this.typeCache = Short.parseShort(var3, var1);
  951.          } catch (NumberFormatException var4) {
  952.             var2 = false;
  953.          }
  954.       }
  955.  
  956.       return var2;
  957.    }
  958.  
  959.    public short nextShort() {
  960.       return this.nextShort(this.defaultRadix);
  961.    }
  962.  
  963.    public short nextShort(int var1) {
  964.       if (this.typeCache != null && this.typeCache instanceof Short && this.radix == var1) {
  965.          short var4 = (Short)this.typeCache;
  966.          this.useTypeCache();
  967.          return var4;
  968.       } else {
  969.          this.setRadix(var1);
  970.          this.clearCaches();
  971.  
  972.          try {
  973.             String var2 = this.next(this.integerPattern());
  974.             if (this.matcher.group(this.SIMPLE_GROUP_INDEX) == null) {
  975.                var2 = this.processIntegerToken(var2);
  976.             }
  977.  
  978.             return Short.parseShort(var2, var1);
  979.          } catch (NumberFormatException var3) {
  980.             this.position = this.matcher.start();
  981.             throw new InputMismatchException(var3.getMessage());
  982.          }
  983.       }
  984.    }
  985.  
  986.    public boolean hasNextInt() {
  987.       return this.hasNextInt(this.defaultRadix);
  988.    }
  989.  
  990.    public boolean hasNextInt(int var1) {
  991.       this.setRadix(var1);
  992.       boolean var2 = this.hasNext(this.integerPattern());
  993.       if (var2) {
  994.          try {
  995.             String var3 = this.matcher.group(this.SIMPLE_GROUP_INDEX) == null ? this.processIntegerToken(this.hasNextResult) : this.hasNextResult;
  996.             this.typeCache = Integer.parseInt(var3, var1);
  997.          } catch (NumberFormatException var4) {
  998.             var2 = false;
  999.          }
  1000.       }
  1001.  
  1002.       return var2;
  1003.    }
  1004.  
  1005.    private String processIntegerToken(String var1) {
  1006.       String var2 = var1.replaceAll("" + this.groupSeparator, "");
  1007.       boolean var3 = false;
  1008.       int var4 = this.negativePrefix.length();
  1009.       if (var4 > 0 && var2.startsWith(this.negativePrefix)) {
  1010.          var3 = true;
  1011.          var2 = var2.substring(var4);
  1012.       }
  1013.  
  1014.       int var5 = this.negativeSuffix.length();
  1015.       if (var5 > 0 && var2.endsWith(this.negativeSuffix)) {
  1016.          var3 = true;
  1017.          var2 = var2.substring(var2.length() - var5, var2.length());
  1018.       }
  1019.  
  1020.       if (var3) {
  1021.          var2 = "-" + var2;
  1022.       }
  1023.  
  1024.       return var2;
  1025.    }
  1026.  
  1027.    public int nextInt() {
  1028.       return this.nextInt(this.defaultRadix);
  1029.    }
  1030.  
  1031.    public int nextInt(int var1) {
  1032.       if (this.typeCache != null && this.typeCache instanceof Integer && this.radix == var1) {
  1033.          int var4 = (Integer)this.typeCache;
  1034.          this.useTypeCache();
  1035.          return var4;
  1036.       } else {
  1037.          this.setRadix(var1);
  1038.          this.clearCaches();
  1039.  
  1040.          try {
  1041.             String var2 = this.next(this.integerPattern());
  1042.             if (this.matcher.group(this.SIMPLE_GROUP_INDEX) == null) {
  1043.                var2 = this.processIntegerToken(var2);
  1044.             }
  1045.  
  1046.             return Integer.parseInt(var2, var1);
  1047.          } catch (NumberFormatException var3) {
  1048.             this.position = this.matcher.start();
  1049.             throw new InputMismatchException(var3.getMessage());
  1050.          }
  1051.       }
  1052.    }
  1053.  
  1054.    public boolean hasNextLong() {
  1055.       return this.hasNextLong(this.defaultRadix);
  1056.    }
  1057.  
  1058.    public boolean hasNextLong(int var1) {
  1059.       this.setRadix(var1);
  1060.       boolean var2 = this.hasNext(this.integerPattern());
  1061.       if (var2) {
  1062.          try {
  1063.             String var3 = this.matcher.group(this.SIMPLE_GROUP_INDEX) == null ? this.processIntegerToken(this.hasNextResult) : this.hasNextResult;
  1064.             this.typeCache = Long.parseLong(var3, var1);
  1065.          } catch (NumberFormatException var4) {
  1066.             var2 = false;
  1067.          }
  1068.       }
  1069.  
  1070.       return var2;
  1071.    }
  1072.  
  1073.    public long nextLong() {
  1074.       return this.nextLong(this.defaultRadix);
  1075.    }
  1076.  
  1077.    public long nextLong(int var1) {
  1078.       if (this.typeCache != null && this.typeCache instanceof Long && this.radix == var1) {
  1079.          long var5 = (Long)this.typeCache;
  1080.          this.useTypeCache();
  1081.          return var5;
  1082.       } else {
  1083.          this.setRadix(var1);
  1084.          this.clearCaches();
  1085.  
  1086.          try {
  1087.             String var2 = this.next(this.integerPattern());
  1088.             if (this.matcher.group(this.SIMPLE_GROUP_INDEX) == null) {
  1089.                var2 = this.processIntegerToken(var2);
  1090.             }
  1091.  
  1092.             return Long.parseLong(var2, var1);
  1093.          } catch (NumberFormatException var4) {
  1094.             this.position = this.matcher.start();
  1095.             throw new InputMismatchException(var4.getMessage());
  1096.          }
  1097.       }
  1098.    }
  1099.  
  1100.    private String processFloatToken(String var1) {
  1101.       String var2 = var1.replaceAll(this.groupSeparator, "");
  1102.       if (!this.decimalSeparator.equals("\\.")) {
  1103.          var2 = var2.replaceAll(this.decimalSeparator, ".");
  1104.       }
  1105.  
  1106.       boolean var3 = false;
  1107.       int var4 = this.negativePrefix.length();
  1108.       if (var4 > 0 && var2.startsWith(this.negativePrefix)) {
  1109.          var3 = true;
  1110.          var2 = var2.substring(var4);
  1111.       }
  1112.  
  1113.       int var5 = this.negativeSuffix.length();
  1114.       if (var5 > 0 && var2.endsWith(this.negativeSuffix)) {
  1115.          var3 = true;
  1116.          var2 = var2.substring(var2.length() - var5, var2.length());
  1117.       }
  1118.  
  1119.       if (var2.equals(this.nanString)) {
  1120.          var2 = "NaN";
  1121.       }
  1122.  
  1123.       if (var2.equals(this.infinityString)) {
  1124.          var2 = "Infinity";
  1125.       }
  1126.  
  1127.       if (var3) {
  1128.          var2 = "-" + var2;
  1129.       }
  1130.  
  1131.       Matcher var6 = NON_ASCII_DIGIT.matcher(var2);
  1132.       if (var6.find()) {
  1133.          StringBuilder var7 = new StringBuilder();
  1134.  
  1135.          for(int var8 = 0; var8 < var2.length(); ++var8) {
  1136.             char var9 = var2.charAt(var8);
  1137.             if (Character.isDigit(var9)) {
  1138.                int var10 = Character.digit(var9, 10);
  1139.                if (var10 != -1) {
  1140.                   var7.append(var10);
  1141.                } else {
  1142.                   var7.append(var9);
  1143.                }
  1144.             } else {
  1145.                var7.append(var9);
  1146.             }
  1147.          }
  1148.  
  1149.          var2 = var7.toString();
  1150.       }
  1151.  
  1152.       return var2;
  1153.    }
  1154.  
  1155.    public boolean hasNextFloat() {
  1156.       this.setRadix(10);
  1157.       boolean var1 = this.hasNext(this.floatPattern());
  1158.       if (var1) {
  1159.          try {
  1160.             String var2 = this.processFloatToken(this.hasNextResult);
  1161.             this.typeCache = Float.parseFloat(var2);
  1162.          } catch (NumberFormatException var3) {
  1163.             var1 = false;
  1164.          }
  1165.       }
  1166.  
  1167.       return var1;
  1168.    }
  1169.  
  1170.    public float nextFloat() {
  1171.       if (this.typeCache != null && this.typeCache instanceof Float) {
  1172.          float var1 = (Float)this.typeCache;
  1173.          this.useTypeCache();
  1174.          return var1;
  1175.       } else {
  1176.          this.setRadix(10);
  1177.          this.clearCaches();
  1178.  
  1179.          try {
  1180.             return Float.parseFloat(this.processFloatToken(this.next(this.floatPattern())));
  1181.          } catch (NumberFormatException var2) {
  1182.             this.position = this.matcher.start();
  1183.             throw new InputMismatchException(var2.getMessage());
  1184.          }
  1185.       }
  1186.    }
  1187.  
  1188.    public boolean hasNextDouble() {
  1189.       this.setRadix(10);
  1190.       boolean var1 = this.hasNext(this.floatPattern());
  1191.       if (var1) {
  1192.          try {
  1193.             String var2 = this.processFloatToken(this.hasNextResult);
  1194.             this.typeCache = Double.parseDouble(var2);
  1195.          } catch (NumberFormatException var3) {
  1196.             var1 = false;
  1197.          }
  1198.       }
  1199.  
  1200.       return var1;
  1201.    }
  1202.  
  1203.    public double nextDouble() {
  1204.       if (this.typeCache != null && this.typeCache instanceof Double) {
  1205.          double var1 = (Double)this.typeCache;
  1206.          this.useTypeCache();
  1207.          return var1;
  1208.       } else {
  1209.          this.setRadix(10);
  1210.          this.clearCaches();
  1211.  
  1212.          try {
  1213.             return Double.parseDouble(this.processFloatToken(this.next(this.floatPattern())));
  1214.          } catch (NumberFormatException var3) {
  1215.             this.position = this.matcher.start();
  1216.             throw new InputMismatchException(var3.getMessage());
  1217.          }
  1218.       }
  1219.    }
  1220.  
  1221.    public boolean hasNextBigInteger() {
  1222.       return this.hasNextBigInteger(this.defaultRadix);
  1223.    }
  1224.  
  1225.    public boolean hasNextBigInteger(int var1) {
  1226.       this.setRadix(var1);
  1227.       boolean var2 = this.hasNext(this.integerPattern());
  1228.       if (var2) {
  1229.          try {
  1230.             String var3 = this.matcher.group(this.SIMPLE_GROUP_INDEX) == null ? this.processIntegerToken(this.hasNextResult) : this.hasNextResult;
  1231.             this.typeCache = new BigInteger(var3, var1);
  1232.          } catch (NumberFormatException var4) {
  1233.             var2 = false;
  1234.          }
  1235.       }
  1236.  
  1237.       return var2;
  1238.    }
  1239.  
  1240.    public BigInteger nextBigInteger() {
  1241.       return this.nextBigInteger(this.defaultRadix);
  1242.    }
  1243.  
  1244.    public BigInteger nextBigInteger(int var1) {
  1245.       if (this.typeCache != null && this.typeCache instanceof BigInteger && this.radix == var1) {
  1246.          BigInteger var4 = (BigInteger)this.typeCache;
  1247.          this.useTypeCache();
  1248.          return var4;
  1249.       } else {
  1250.          this.setRadix(var1);
  1251.          this.clearCaches();
  1252.  
  1253.          try {
  1254.             String var2 = this.next(this.integerPattern());
  1255.             if (this.matcher.group(this.SIMPLE_GROUP_INDEX) == null) {
  1256.                var2 = this.processIntegerToken(var2);
  1257.             }
  1258.  
  1259.             return new BigInteger(var2, var1);
  1260.          } catch (NumberFormatException var3) {
  1261.             this.position = this.matcher.start();
  1262.             throw new InputMismatchException(var3.getMessage());
  1263.          }
  1264.       }
  1265.    }
  1266.  
  1267.    public boolean hasNextBigDecimal() {
  1268.       this.setRadix(10);
  1269.       boolean var1 = this.hasNext(this.decimalPattern());
  1270.       if (var1) {
  1271.          try {
  1272.             String var2 = this.processFloatToken(this.hasNextResult);
  1273.             this.typeCache = new BigDecimal(var2);
  1274.          } catch (NumberFormatException var3) {
  1275.             var1 = false;
  1276.          }
  1277.       }
  1278.  
  1279.       return var1;
  1280.    }
  1281.  
  1282.    public BigDecimal nextBigDecimal() {
  1283.       if (this.typeCache != null && this.typeCache instanceof BigDecimal) {
  1284.          BigDecimal var3 = (BigDecimal)this.typeCache;
  1285.          this.useTypeCache();
  1286.          return var3;
  1287.       } else {
  1288.          this.setRadix(10);
  1289.          this.clearCaches();
  1290.  
  1291.          try {
  1292.             String var1 = this.processFloatToken(this.next(this.decimalPattern()));
  1293.             return new BigDecimal(var1);
  1294.          } catch (NumberFormatException var2) {
  1295.             this.position = this.matcher.start();
  1296.             throw new InputMismatchException(var2.getMessage());
  1297.          }
  1298.       }
  1299.    }
  1300.  
  1301.    public Scanner reset() {
  1302.       this.delimPattern = WHITESPACE_PATTERN;
  1303.       this.useLocale(Locale.getDefault());
  1304.       this.useRadix(10);
  1305.       this.clearCaches();
  1306.       return this;
  1307.    }
  1308. }
  1309.